void solve()
{
	int n;
	cin >> n;

	vector<vector<int>> p(3, vector<int>(n + 1));
	vector<set<pii>> S(3);

	for (int i = 0; i < 3; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> p[i][j];
			S[i].insert({p[i][j], j});
		}
	}

	vector<pair<int, char>> pre(n + 1);
	vector<int> dis(n + 1, inf);
	auto get = [&](int k) {
		if (k == 0) {
			return 'q';
		} else if (k == 1) {
			return 'k';
		}
		return 'j';
	};
	auto del = [&](vector<int> vec) {
		for (int i = 0; i < 3; i++) {
			for (auto &v : vec) {
				S[i].erase({p[i][v], v});
			}
		}
	};
	del({1});
	queue<int> Q;
	auto move = [&](int k, int v) {
		if (S[k].size() == 0) {
			return;
		}
		vector<int> vec;
		auto it = S[k].begin();
		while (it != S[k].end() && it->first <= p[k][v]) {
			if (it->second > v) {
				if (dis[it->second] == inf) {
					dis[it->second] = 1;
					pre[it->second] = {v, get(k)};
					vec.push_back(it->second);
					Q.push(it->second);
				}
			}
			it++;
		}
		del(vec);
	};
	Q.push(1);
	dis[1] = 1;
	while (!Q.empty()) {
		int v = Q.front();
		Q.pop();
		for (int i = 0; i < 3; i++) {
			move(i, v);
		}
	}

	if (dis[n] != inf) {
		cout << "YES" << '\n';
		vector<pair<char, int>> road;
		int pos = n;
		while (pos != 1) {
			road.push_back({pre[pos].second, pos});
			pos = pre[pos].first;
		}
		reverse(road.begin(), road.end());
		cout << road.size() << '\n';
		for (auto &[x, c] : road) {
			cout << x << ' ' << c << '\n';
		}
	} else {
		cout << "NO" << '\n';
	}
}